﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SdlDotNet.Graphics;
using SdlDotNet.Graphics.Sprites;
using System.IO;
using System.Drawing;


namespace bloodbox
{
    class SpriteDrawer
    {
        private Surface SHsurface;

        private AnimatedSprite sorceror = new AnimatedSprite();

        private Size sprite_size = new Size(96, 96);

        public SpriteDrawer(Surface surface)
        {
            SHsurface = surface;
        }
        /*
        public void displaySprite(Surface image, Point point) {

            
        
        } */

        public void loadPlayerSprite()
        {

            

            // SORCEROR ----------------------------------------------

            // Load the tileset image
            Surface image = new Surface(Path.Combine("tiles", Path.Combine("persons","sorceror.png")));
            image.TransparentColor = Color.Magenta;
            image.Transparent = true;

            // Create the animation frames
            SurfaceCollection sorceror_walk_down  = new SurfaceCollection();
            SurfaceCollection sorceror_walk_left  = new SurfaceCollection();
            SurfaceCollection sorceror_walk_up    = new SurfaceCollection();
            SurfaceCollection sorceror_walk_right = new SurfaceCollection();

            sorceror_walk_down.Add(image, sprite_size, 0);
            sorceror_walk_left.Add(image, sprite_size, 1);
            sorceror_walk_up.Add(image, sprite_size, 2);
            sorceror_walk_right.Add(image, sprite_size, 3);

            // Add the animations to the hero
            AnimationCollection animSorceror_walk_down  = new AnimationCollection();
            AnimationCollection animSorceror_walk_left  = new AnimationCollection();
            AnimationCollection animSorceror_walk_up    = new AnimationCollection();
            AnimationCollection animSorceror_walk_right = new AnimationCollection();

            animSorceror_walk_down.Add(sorceror_walk_down, 35);
            animSorceror_walk_left.Add(sorceror_walk_left, 35);
            animSorceror_walk_up.Add(sorceror_walk_up, 35);
            animSorceror_walk_right.Add(sorceror_walk_right, 35);

            sorceror.Animations.Add("WalkDown", animSorceror_walk_down);
            sorceror.Animations.Add("WalkLeft", animSorceror_walk_left);
            sorceror.Animations.Add("WalkUp",   animSorceror_walk_up);
            sorceror.Animations.Add("WalkRight",animSorceror_walk_right);
            // Change the transparent color of the sprite
            
            
        }

        public void animateSprite(string sprite, string animation, Point point, bool animate)
        {
            // Setup the startup animation and make him not walk
            sorceror.CurrentAnimation = animation;
            sorceror.Animate = true;
            sorceror.Center = point;
            SHsurface.Blit(sorceror);
        }
    }
}
